using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.skill
{
[System.Serializable]
public  class Skill :   cfg.EditorReadWriter 
 {

    public int id ;
     public string name  = "";
     public string description  = "";
     public cfg.equip.EWeaponType weaponLimit ;
     public bool isNormalAttack ;
     public int combo ;
     public float coolDown ;
     public bool immuneToControl ;
     public cfg.skill.HasteType hasteType ;
     public bool allowOtherCast ;
     public bool canCastinOther ;
     public System.Collections.Generic.List<cfg.role.RelationType> autoTarget  = new System.Collections.Generic.List<cfg.role.RelationType>();
     public string joystick  = "";
     public float warningRadius ;
     public float innerX ;
     public float innerZ ;
     public cfg.skill.InnerType innerType ;
     public string cost  = "";
     public string blueprintName  = "";
     public string icon  = "";
     public System.Collections.Generic.List<cfg.skill.HitPointAction> skillEvents  = new System.Collections.Generic.List<cfg.skill.HitPointAction>();
     


    public const int TYPE_ID = 1539215818;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(21);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(id);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.STRING | (3 << Tag.TAG_SHIFT));  os.WriteString(description);  
         os.WriteSize(Tag.INT | (4 << Tag.TAG_SHIFT));  os.WriteInt((int)weaponLimit);  
         os.WriteSize(Tag.BOOL | (5 << Tag.TAG_SHIFT));  os.WriteBool(isNormalAttack);  
         os.WriteSize(Tag.INT | (6 << Tag.TAG_SHIFT));  os.WriteInt(combo);  
         os.WriteSize(Tag.FLOAT | (7 << Tag.TAG_SHIFT));  os.WriteFloat(coolDown);  
         os.WriteSize(Tag.BOOL | (8 << Tag.TAG_SHIFT));  os.WriteBool(immuneToControl);  
         os.WriteSize(Tag.INT | (9 << Tag.TAG_SHIFT));  os.WriteInt((int)hasteType);  
         os.WriteSize(Tag.BOOL | (10 << Tag.TAG_SHIFT));  os.WriteBool(allowOtherCast);  
         os.WriteSize(Tag.BOOL | (11 << Tag.TAG_SHIFT));  os.WriteBool(canCastinOther);  
         os.WriteSize(Tag.LIST | (12 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_role_RelationType(autoTarget,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.STRING | (13 << Tag.TAG_SHIFT));  os.WriteString(joystick);  
         os.WriteSize(Tag.FLOAT | (14 << Tag.TAG_SHIFT));  os.WriteFloat(warningRadius);  
         os.WriteSize(Tag.FLOAT | (15 << Tag.TAG_SHIFT));  os.WriteFloat(innerX);  
         os.WriteSize(Tag.FLOAT | (16 << Tag.TAG_SHIFT));  os.WriteFloat(innerZ);  
         os.WriteSize(Tag.INT | (17 << Tag.TAG_SHIFT));  os.WriteInt((int)innerType);  
         os.WriteSize(Tag.STRING | (18 << Tag.TAG_SHIFT));  os.WriteString(cost);  
         os.WriteSize(Tag.STRING | (19 << Tag.TAG_SHIFT));  os.WriteString(blueprintName);  
         os.WriteSize(Tag.STRING | (20 << Tag.TAG_SHIFT));  os.WriteString(icon);  
         os.WriteSize(Tag.LIST | (21 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_skill_HitPointAction(skillEvents,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   id = os.ReadInt(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.STRING | (3 << Tag.TAG_SHIFT)):   description = os.ReadString(); break;  
             case (Tag.INT | (4 << Tag.TAG_SHIFT)):   weaponLimit = (cfg.equip.EWeaponType)(os.ReadInt()); break;  
             case (Tag.BOOL | (5 << Tag.TAG_SHIFT)):   isNormalAttack = os.ReadBool(); break;  
             case (Tag.INT | (6 << Tag.TAG_SHIFT)):   combo = os.ReadInt(); break;  
             case (Tag.FLOAT | (7 << Tag.TAG_SHIFT)):   coolDown = os.ReadFloat(); break;  
             case (Tag.BOOL | (8 << Tag.TAG_SHIFT)):   immuneToControl = os.ReadBool(); break;  
             case (Tag.INT | (9 << Tag.TAG_SHIFT)):   hasteType = (cfg.skill.HasteType)(os.ReadInt()); break;  
             case (Tag.BOOL | (10 << Tag.TAG_SHIFT)):   allowOtherCast = os.ReadBool(); break;  
             case (Tag.BOOL | (11 << Tag.TAG_SHIFT)):   canCastinOther = os.ReadBool(); break;  
             case (Tag.LIST | (12 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); autoTarget = cfg.Extensions.unmarshal_compatible_list_cfg_role_RelationType(os); os = _oldOs; break; }   
             case (Tag.STRING | (13 << Tag.TAG_SHIFT)):   joystick = os.ReadString(); break;  
             case (Tag.FLOAT | (14 << Tag.TAG_SHIFT)):   warningRadius = os.ReadFloat(); break;  
             case (Tag.FLOAT | (15 << Tag.TAG_SHIFT)):   innerX = os.ReadFloat(); break;  
             case (Tag.FLOAT | (16 << Tag.TAG_SHIFT)):   innerZ = os.ReadFloat(); break;  
             case (Tag.INT | (17 << Tag.TAG_SHIFT)):   innerType = (cfg.skill.InnerType)(os.ReadInt()); break;  
             case (Tag.STRING | (18 << Tag.TAG_SHIFT)):   cost = os.ReadString(); break;  
             case (Tag.STRING | (19 << Tag.TAG_SHIFT)):   blueprintName = os.ReadString(); break;  
             case (Tag.STRING | (20 << Tag.TAG_SHIFT)):   icon = os.ReadString(); break;  
             case (Tag.LIST | (21 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); skillEvents = cfg.Extensions.unmarshal_compatible_list_cfg_skill_HitPointAction(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Skill");
        ele.WriteStartElement("id"); ele.WriteAttributeString("id", "1"); ele.WriteInt(id); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "2"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("description"); ele.WriteAttributeString("id", "3"); ele.WriteString2(description); ele.WriteEndElement();
         ele.WriteStartElement("weaponLimit"); ele.WriteAttributeString("id", "4"); ele.WriteEnum(weaponLimit); ele.WriteEndElement();
         ele.WriteStartElement("isNormalAttack"); ele.WriteAttributeString("id", "5"); ele.WriteBool(isNormalAttack); ele.WriteEndElement();
         ele.WriteStartElement("combo"); ele.WriteAttributeString("id", "6"); ele.WriteInt(combo); ele.WriteEndElement();
         ele.WriteStartElement("coolDown"); ele.WriteAttributeString("id", "7"); ele.WriteFloat(coolDown); ele.WriteEndElement();
         ele.WriteStartElement("immuneToControl"); ele.WriteAttributeString("id", "8"); ele.WriteBool(immuneToControl); ele.WriteEndElement();
         ele.WriteStartElement("hasteType"); ele.WriteAttributeString("id", "9"); ele.WriteEnum(hasteType); ele.WriteEndElement();
         ele.WriteStartElement("allowOtherCast"); ele.WriteAttributeString("id", "10"); ele.WriteBool(allowOtherCast); ele.WriteEndElement();
         ele.WriteStartElement("canCastinOther"); ele.WriteAttributeString("id", "11"); ele.WriteBool(canCastinOther); ele.WriteEndElement();
         ele.WriteStartElement("autoTarget"); ele.WriteAttributeString("id", "12"); cfg.Extensions.xml_marshal_list_cfg_role_RelationType(autoTarget,ele); ele.WriteEndElement();
         ele.WriteStartElement("joystick"); ele.WriteAttributeString("id", "13"); ele.WriteString2(joystick); ele.WriteEndElement();
         ele.WriteStartElement("warningRadius"); ele.WriteAttributeString("id", "14"); ele.WriteFloat(warningRadius); ele.WriteEndElement();
         ele.WriteStartElement("innerX"); ele.WriteAttributeString("id", "15"); ele.WriteFloat(innerX); ele.WriteEndElement();
         ele.WriteStartElement("innerZ"); ele.WriteAttributeString("id", "16"); ele.WriteFloat(innerZ); ele.WriteEndElement();
         ele.WriteStartElement("innerType"); ele.WriteAttributeString("id", "17"); ele.WriteEnum(innerType); ele.WriteEndElement();
         ele.WriteStartElement("cost"); ele.WriteAttributeString("id", "18"); ele.WriteString2(cost); ele.WriteEndElement();
         ele.WriteStartElement("blueprintName"); ele.WriteAttributeString("id", "19"); ele.WriteString2(blueprintName); ele.WriteEndElement();
         ele.WriteStartElement("icon"); ele.WriteAttributeString("id", "20"); ele.WriteString2(icon); ele.WriteEndElement();
         ele.WriteStartElement("skillEvents"); ele.WriteAttributeString("id", "21"); cfg.Extensions.xml_marshal_list_cfg_skill_HitPointAction(skillEvents,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  id = ele.ReadInt(); break; 
                 case 2:  name = ele.ReadString2(); break; 
                 case 3:  description = ele.ReadString2(); break; 
                 case 4:  weaponLimit = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case 5:  isNormalAttack = ele.ReadBool(); break; 
                 case 6:  combo = ele.ReadInt(); break; 
                 case 7:  coolDown = ele.ReadFloat(); break; 
                 case 8:  immuneToControl = ele.ReadBool(); break; 
                 case 9:  hasteType = ele.ReadEnum<cfg.skill.HasteType>(); break; 
                 case 10:  allowOtherCast = ele.ReadBool(); break; 
                 case 11:  canCastinOther = ele.ReadBool(); break; 
                 case 12:  autoTarget = cfg.Extensions.xml_unmarshal_list_cfg_role_RelationType(ele); break; 
                 case 13:  joystick = ele.ReadString2(); break; 
                 case 14:  warningRadius = ele.ReadFloat(); break; 
                 case 15:  innerX = ele.ReadFloat(); break; 
                 case 16:  innerZ = ele.ReadFloat(); break; 
                 case 17:  innerType = ele.ReadEnum<cfg.skill.InnerType>(); break; 
                 case 18:  cost = ele.ReadString2(); break; 
                 case 19:  blueprintName = ele.ReadString2(); break; 
                 case 20:  icon = ele.ReadString2(); break; 
                 case 21:  skillEvents = cfg.Extensions.xml_unmarshal_list_cfg_skill_HitPointAction(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "id":  id = ele.ReadInt(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "description":  description = ele.ReadString2(); break; 
                 case "weapon_limit":  weaponLimit = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case "is_normal_attack":  isNormalAttack = ele.ReadBool(); break; 
                 case "combo":  combo = ele.ReadInt(); break; 
                 case "cool_down":  coolDown = ele.ReadFloat(); break; 
                 case "immune_to_control":  immuneToControl = ele.ReadBool(); break; 
                 case "haste_type":  hasteType = ele.ReadEnum<cfg.skill.HasteType>(); break; 
                 case "allow_other_cast":  allowOtherCast = ele.ReadBool(); break; 
                 case "can_castin_other":  canCastinOther = ele.ReadBool(); break; 
                 case "auto_target":  autoTarget = cfg.Extensions.xml_unmarshal_list_cfg_role_RelationType(ele); break; 
                 case "joystick":  joystick = ele.ReadString2(); break; 
                 case "warning_radius":  warningRadius = ele.ReadFloat(); break; 
                 case "inner_x":  innerX = ele.ReadFloat(); break; 
                 case "inner_z":  innerZ = ele.ReadFloat(); break; 
                 case "inner_type":  innerType = ele.ReadEnum<cfg.skill.InnerType>(); break; 
                 case "cost":  cost = ele.ReadString2(); break; 
                 case "blueprint_name":  blueprintName = ele.ReadString2(); break; 
                 case "icon":  icon = ele.ReadString2(); break; 
                 case "skill_events":  skillEvents = cfg.Extensions.xml_unmarshal_list_cfg_skill_HitPointAction(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
